<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: new_event.tpl.php 1151 2008-06-24 15:07:32Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 
?>
<div class="slider" id="slide_newEvent" style="border:solid 1px;">
<form id="newEventForm" name="newEventForm" 
      action="javascript: jl_PostForm( serializeLineupForm(document.getElementById('newEventForm')), 'editarea');"
      enctype="application/x-www-form-urlencoded">
 
<input type="hidden" name="option" id="option" value="com_joomleague" />
<input type="hidden" name="no_html" id="no_html" value="1" />
<input type="hidden" name="mytask" id="mytask" value="saveevent" />
<input type="hidden" name="func" id="func" value="editEvents" />
<input type="hidden" name="act" value="editEvents" />
<input type="hidden" name="p" id="p" value="<?php echo $this->project->id;?>" />
<input type="hidden" name="mid" id="match_id" value="<?php echo $this->match->match_id;?>" />
<input type="hidden" name="player_id" id="player_id" value="" />
<input type="hidden" name="player_id2" id="player_id2" value="" />
<input type="hidden" name="team_id" id="team_id" value="" />
<input type="hidden" name="event_player_double" id="event_player_double" value="0" />
<input type="hidden" name="event_notice" id="event_notice" value="0" />

<table width="100%" cellspacing="0">
	<tr class="sectiontableentry1">
		<td colspan="3"><b><?php echo _JL_ADMIN_EDIT_FORM_EVENTTYPES_TITLE_NEW.":";?></b><br />
	</tr>
	<tr class="sectiontableentry1">
		<td colspan="3" nowrap="nowrap">
    <select name="event_type_id" 
            id="event_type_id" 
            class="inputbox" 
            onclick="SplitName = this.options[this.selectedIndex].title.split('-');
                     document.getElementById('event_player_double').value = SplitName[0];
                     document.getElementById('event_notice').value = SplitName[1];
                     if (getElementById('event_player_double').value==1) {
                        document.getElementById('showguestteam2').style.display='inline';
                        document.getElementById('showhometeam2').style.display='inline';
                     } 
                     else {
                        document.getElementById('showguestteam2').style.display='none';
                        document.getElementById('showhometeam2').style.display='none';
    					document.getElementById('player_id2').value = 0;
						document.getElementById('home_player_id2').value = 0;
						document.getElementById('guest_player_id2').value = 0;
                     }
                     <?php if ($events_required) { ?>
    				 if (((document.getElementById('event_player_double').value == 1 && document.getElementById('player_id2').value != 0)
                                 || (document.getElementById('event_player_double').value == 0 && document.getElementById('player_id').value != 0))
                       && ((document.getElementById('event_notice').value == 1 && document.getElementById('notice').value != '')
                                 || (document.getElementById('event_notice').value == 0))
                       && document.getElementById('event_type_id').value != 0
                       && document.getElementById('event_sum').value > 0) 
                     {
						document.getElementById('submitter').disabled=false;
					 } else document.getElementById('submitter').disabled=true;<?php } ?>">
      <?php
      echo '<option value="0" title="0">'.jl_utf8_convert(_JL_ADMIN_SELECT_EVENT).'</option>';
      foreach ($eventtypes AS $eventtype) {
        echo '<option value="'.$eventtype->id.'"';
        echo ' title="'.$eventtype->double.'-'.$eventtype->splitt.'"';
        echo '>'.jl_utf8_convert($eventtype->name).'</option> \n';
      }
      ?>
			</select>
      <?php echo _JL_ADMIN_EDIT_FORM_MATCHEVENTS_MINUTE;?>&nbsp;
      <input type="text" name="event_time" id="event_time" size="3" class="inputbox" value="" />
      
      <?php echo _JL_NOTICE;?>:&nbsp;
      <input type="text" name="notice" id="notice" size="20" class="inputbox" value=""<?php echo ($events_required) ? ' onkeyup="if (((document.getElementById(\'event_player_double\').value == 1 && document.getElementById(\'player_id2\').value != 0)
                                 || (document.getElementById(\'event_player_double\').value == 0 && document.getElementById(\'player_id\').value != 0))
                       && ((document.getElementById(\'event_notice\').value == 1 && document.getElementById(\'notice\').value != \'\')
                                 || (document.getElementById(\'event_notice\').value == 0))
                       && document.getElementById(\'event_type_id\').value != 0
                       && document.getElementById(\'event_sum\').value > 0) 
                     {
						document.getElementById(\'submitter\').disabled=false;
					 } else document.getElementById(\'submitter\').disabled=true;"' : ''; ?> />&nbsp;
      
      <?php echo _JL_ADMIN_EDIT_FORM_MATCHEVENTS_SUM;?>&nbsp;
      <input type="text" name="event_sum" id="event_sum" size="3" class="inputbox" value="1" <?php echo ($events_required) ? ' onkeyup="if (((document.getElementById(\'event_player_double\').value == 1 && document.getElementById(\'player_id2\').value != 0)
                                 || (document.getElementById(\'event_player_double\').value == 0 && document.getElementById(\'player_id\').value != 0))
                       && ((document.getElementById(\'event_notice\').value == 1 && document.getElementById(\'notice\').value != \'\')
                                 || (document.getElementById(\'event_notice\').value == 0))
                       && document.getElementById(\'event_type_id\').value != 0
                       && document.getElementById(\'event_sum\').value > 0) 
                     {
						document.getElementById(\'submitter\').disabled=false;
					 } else document.getElementById(\'submitter\').disabled=true;"' : ''; ?> />&nbsp;
      
      <input type="submit" name="button" id="submitter" value="<?php echo _JL_SAVE;?>" class="inputbox"<?php echo ($events_required) ? ' disabled="disabled"' : ''; ?> />
		</td>
	</tr>
	<tr class="sectiontableentry1">
		<td width="50%"><b><?php echo jl_utf8_convert($team1->name);?></b></td>
        <td>&nbsp;</td>
		<td width="50%"><b><?php echo jl_utf8_convert($team2->name);?></b></td>
	</tr>
	<tr class="sectiontableentry1">
		<td>
    <?php
    echo _JL_ADMIN_EDIT_FORM_EVENTTYPES_PLAYER1; ?>
    <select name="home_player_id" 
    				id="home_player_id" 
    				class="inputbox" 
    				onchange="if ( this.selectedIndex!=0 ) {
    										document.getElementById('guest_player_id').disabled = true;
    										document.getElementById('guest_player_id2').disabled = true;
    										document.getElementById('player_id').value = this.options[this.selectedIndex].value;
    										document.getElementById('team_id').value = <?php echo $team1->id;?>;
    										<?php if ($events_required) { ?>
    										if (((document.getElementById('event_player_double').value == 1 && document.getElementById('player_id2').value != 0)
                                                          || (document.getElementById('event_player_double').value == 0))
                                               && ((document.getElementById('event_notice').value == 1 && document.getElementById('notice').value != '')
                                                          || (document.getElementById('event_notice').value == 0))
                                               && document.getElementById('event_type_id').value != 0
                                               && document.getElementById('event_sum').value > 0) {
												document.getElementById('submitter').disabled=false;
											}
											<?php } ?>
    									} else {
    										document.getElementById('player_id').value = 0;
    										if (document.getElementById('player_id').value == 0 && document.getElementById('player_id2').value == 0) {
    										  document.getElementById('guest_player_id').disabled=false;
    										  document.getElementById('guest_player_id2').disabled=false;
    										  document.getElementById('team_id').value = 0;
    										}
									        <?php echo ($events_required) ? 'document.getElementById(\'submitter\').disabled=true;' : ''; ?>
    									}">
    <?php
    foreach ($homeoptions AS $player_id => $player) {
      echo '<option value="'.$player_id.'">'.$player.'</option>';
    }
    ?>
    </select>
    <DIV id="showhometeam2" style="display:none"><BR />
    <?php echo _JL_ADMIN_EDIT_FORM_EVENTTYPES_PLAYER2; ?>
    <select name="home_player_id2" 
    				id="home_player_id2" 
    				class="inputbox" 
    				onchange="if ( this.selectedIndex!=0 ) {
    										document.getElementById('guest_player_id').disabled = true;
    										document.getElementById('guest_player_id2').disabled = true;
    										document.getElementById('player_id2').value = this.options[this.selectedIndex].value;
    										document.getElementById('team_id').value = <?php echo $team1->id;?>;
    										<?php if ($events_required) { ?>
    										if (document.getElementById('player_id').value != 0 && document.getElementById('event_sum').value > 0
                                               && ((document.getElementById('event_notice').value == 1 && document.getElementById('notice').value != '')
                                                          || (document.getElementById('event_notice').value == 0))) {
												document.getElementById('submitter').disabled=false;
											}
											<?php } ?>
    									} else {
    										document.getElementById('player_id2').value = 0;
    										if (document.getElementById('player_id').value == 0 && document.getElementById('player_id2').value == 0) {
    										  document.getElementById('guest_player_id').disabled=false;
    										  document.getElementById('guest_player_id2').disabled=false;
    										  document.getElementById('team_id').value = 0;
    										}
									        <?php echo ($events_required) ? 'document.getElementById(\'submitter\').disabled=true;' : ''; ?>
    									}">
    <?php
    foreach ($homeoptions AS $player_id => $player) {
      echo '<option value="'.$player_id.'">'.$player.'</option>';
    }
    ?>
    </select>
    </DIV>

    </td>
		<td>&nbsp;</td><td>
    <?php
    echo _JL_ADMIN_EDIT_FORM_EVENTTYPES_PLAYER1; ?>
    <select name="guest_player_id" 
    				id="guest_player_id" 
    				class="inputbox" 
    				onchange="if ( this.selectedIndex!=0 ) {
    										document.getElementById('home_player_id').disabled = true;
    										document.getElementById('home_player_id2').disabled = true;
    										document.getElementById('player_id').value = this.options[this.selectedIndex].value;
    										document.getElementById('team_id').value = <?php echo $team2->id;?>;
    										<?php if ($events_required) { ?>
    										if (((document.getElementById('event_player_double').value == 1 && document.getElementById('player_id2').value != 0)
                                                          || (document.getElementById('event_player_double').value == 0))
                                               && ((document.getElementById('event_notice').value == 1 && document.getElementById('notice').value != '')
                                                          || (document.getElementById('event_notice').value == 0))
                                               && document.getElementById('event_type_id').value != 0
                                               && document.getElementById('event_sum').value > 0) {
												document.getElementById('submitter').disabled=false;
											}
											<?php } ?>
    									} else {
    										document.getElementById('player_id').value = 0;
    										if (document.getElementById('player_id').value == 0 && document.getElementById('player_id2').value == 0) {
    										  document.getElementById('home_player_id').disabled=false;
    										  document.getElementById('home_player_id2').disabled=false;
    										  document.getElementById('team_id').value=0;
    										}
									        <?php echo ($events_required) ? 'document.getElementById(\'submitter\').disabled=true;' : ''; ?>
    									}">
    <?php
    foreach ($guestoptions AS $player_id => $player) {
      echo '<option value="'.$player_id.'">'.$player.'</option>';
    }
    ?>
    </select><DIV id="showguestteam2" style="display:none"><BR />
    <?php echo _JL_ADMIN_EDIT_FORM_EVENTTYPES_PLAYER2; ?>
    <select name="guest_player_id2" 
    				id="guest_player_id2" 
    				class="inputbox" 
    				onchange="if ( this.selectedIndex!=0 ) {
    										document.getElementById('home_player_id').disabled = true;
    										document.getElementById('home_player_id2').disabled = true;
    										document.getElementById('player_id2').value = this.options[this.selectedIndex].value;
    										document.getElementById('team_id').value = <?php echo $team2->id;?>;
    										<?php if ($events_required) { ?>
    										if (document.getElementById('player_id').value != 0 && document.getElementById('event_sum').value > 0
                                               && ((document.getElementById('event_notice').value == 1 && document.getElementById('notice').value != '')
                                                          || (document.getElementById('event_notice').value == 0))) {
												document.getElementById('submitter').disabled=false;
											}
											<?php } ?>
    									} else {
    										document.getElementById('player_id2').value = 0;
    										if (document.getElementById('player_id').value == 0 && document.getElementById('player_id2').value == 0) {
    										  document.getElementById('home_player_id').disabled=false;
    										  document.getElementById('home_player_id2').disabled=false;
    										  document.getElementById('team_id').value=0;
    										}
									        <?php echo ($events_required) ? 'document.getElementById(\'submitter\').disabled=true;' : ''; ?>
    									}">
    <?php
    foreach ($guestoptions AS $player_id => $player) {
      echo '<option value="'.$player_id.'">'.$player.'</option>';
    }
    ?>
    </select></DIV>
    </td>
	</tr>
</table>
</form>
</div>

